#include <vector>

#include "pr/TestResult.h"

namespace pr {

TestResult::TestResult(std::size_t patternCount)
  : patternCount_(patternCount)
{
}

void TestResult::clear()
{
  errors_ = std::vector<Error>();
}

void TestResult::addError(const UniquePattern& pattern, std::size_t computedClassId)
{
  errors_.push_back(Error(pattern, computedClassId));
}

const UniquePattern& TestResult::getError(std::size_t index, std::size_t& computedClassId) const
{
  const Error& error = errors_[index];
  computedClassId = error.ComputedClassId;
  return error.ErrorPattern;
}

std::size_t TestResult::errorCount() const
{
  return errors_.size();
}

double TestResult::errorRate() const
{
  return (double)errors_.size() / patternCount_;
}

} // namespace pr
